package com.example.apen.usdkdemo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者 Y_MS
 * Created by ${APEN} on 2017/5/23.
 * GitHub：https://github.com/cxydxpx
 */

public class PosActivity extends AppCompatActivity implements View.OnClickListener {

    @BindView(R.id.tv_result)
    TextView mResult;

    @BindView(R.id.btn_back)
    Button mBack;

    @BindView(R.id.btn_clear)
    Button mClear;

    @BindView(R.id.btn_define)
    Button mDefine;

    @BindView(R.id.btn_add)
    Button mAdd;

    @BindView(R.id.btn_point)
    Button mPoint;

    @BindView(R.id.btn_0)
    Button m_0;

    @BindView(R.id.btn_1)
    Button m_1;

    @BindView(R.id.btn_2)
    Button m_2;

    @BindView(R.id.btn_3)
    Button m_3;

    @BindView(R.id.btn_4)
    Button m_4;

    @BindView(R.id.btn_5)
    Button m_5;

    @BindView(R.id.btn_6)
    Button m_6;

    @BindView(R.id.btn_7)
    Button m_7;

    @BindView(R.id.btn_8)
    Button m_8;

    @BindView(R.id.btn_9)
    Button m_9;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pos);
        ButterKnife.bind(this);
        initListener();
    }

    private void initListener() {
        mBack.setOnClickListener(this);
        mClear.setOnClickListener(this);
        mDefine.setOnClickListener(this);
        mAdd.setOnClickListener(this);
        mPoint.setOnClickListener(this);
        m_0.setOnClickListener(this);
        m_1.setOnClickListener(this);
        m_2.setOnClickListener(this);
        m_3.setOnClickListener(this);
        m_4.setOnClickListener(this);
        m_5.setOnClickListener(this);
        m_6.setOnClickListener(this);
        m_7.setOnClickListener(this);
        m_8.setOnClickListener(this);
        m_9.setOnClickListener(this);
    }
    private StringBuffer tvPrice = new StringBuffer("");
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_back:
                break;
            case R.id.btn_clear:
                mResult.setText(tvPrice);
                break;
            case R.id.btn_define:
                finish();
                break;
            case R.id.btn_add:
                break;
            case R.id.btn_point:
                mResult.append(".");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_0:
                mResult.append("0");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_1:
                mResult.append("1");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_2:
                mResult.append("2");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_3:
                mResult.append("3");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_4:
                mResult.append("4");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_5:
                mResult.append("5");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_6:
                mResult.append("6");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_7:
                mResult.append("7");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_8:
                mResult.append("8");
                mResult.setText(tvPrice);
                break;
            case R.id.btn_9:
                mResult.append("9");
                mResult.setText(tvPrice);
                break;
            default:
                break;
        }
    }
}
